// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1069

//#define COMPILE
#ifdef COMPILE

#include <fstream>
using namespace std;

int number[10];

void input() {
	ifstream in("input.txt");

	for (int i = 0; i < 10; i++) {
		int j;
		in >> j;
		while (j > 9) {
			int k = j;
			int sum = 0;
			while (k > 0) {
				sum += k % 10;
				k /= 10;
			}
			j = sum;
		}
		number[j]++;
	}

	in.close();
}

void output() {
	ofstream out("output.txt");

	int j = 1;
	for (int i = 1; i < 10; i++) {
		if (number[i] > number[j])
			j = i;
	}

	for (int k = 1; k < 10; k++) {
		if (number[k] == number[j])
			out << k << " ";
	}

	out.close();
}

int main() {
	input();

	output();

	return 0;
}
#endif
